package com.sc.reducer;

import java.io.IOException;

import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import com.sc.bean.Spend;

public class StaffComputeSortReducer extends Reducer<Text, FloatWritable, FloatWritable, Spend> {

	Spend spend = new Spend();
	FloatWritable moneyf = new FloatWritable();
	
	@Override
	protected void reduce(Text arg0, Iterable<FloatWritable> arg1,
			Reducer<Text, FloatWritable, FloatWritable, Spend>.Context arg2) throws IOException, InterruptedException {
		// TODO Auto-generated method stub
		float money = 0;
		for (FloatWritable m : arg1) {
			money += m.get();
		}
		spend.setName(arg0);
		moneyf.set(money);
		spend.setMoney(moneyf);
		arg2.write(moneyf, spend);
	}
}
